package com.ballgame;

import java.awt.*;

//爆炸类
public class Explode {
    double x,y;
    //static静态属性在类里加载一次，如果在其他的位置，每次运行都要加载，占用内存
    static Image[] imgs = new Image[16];

    static {
        for (int i=0;i<16;i++){
            imgs[i] = GameUtil01.getImage("images01/explode/e"+(i+1)+".gif");
            //懒加载
            imgs[i].getWidth(null);
        }
    }
    //加载后要画出来
    boolean live = true;
    int count;
    public void draw(Graphics g){
        if(!live){
            return;
        }

        if(count<16){
            g.drawImage(imgs[count],(int)x,(int)y,null );
            count++;
        }else {
            live = false;
        }
    }
    //传方位入爆炸位置
    public Explode(double x, double y) {
        this.x = x;
        this.y = y;
    }
}
